package cn.ad.server.persistence;

import cn.ad.server.persistence.dao.AmountStoreDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.ad.server.domain.ad.AmountStore;

@Repository
public class AmountStoreRepositoryImpl implements AmountStoreRepository {

	@Autowired
	private AmountStoreDao amountStoreDao;

	@Override
	public void saveOrUpdate(AmountStore as) {
		AmountStore as1 = amountStoreDao.findByKey(as.getCacheKey());
		if (as1 == null) {
			amountStoreDao.save(as);
		} else {
			as1.setAmount(as.getAmount());
			amountStoreDao.update(as1);
		}
	}

}
